package com.crealth.model;

import java.io.Serializable;
import java.sql.Timestamp;

import com.alibaba.fastjson.JSONObject;

public class LoanContractModel implements Serializable {
	private static final long serialVersionUID = 714805L;
	
	public static final int Contract_Saved = 3;  // 合同已录入
	public static final int Contract_Printed = 4;  // 合同已打印
	public static final int Contract_Signed = 5;  // 合同已签
	
	private int id;
	private String contractNo;  //  合同编号
	private int companyID;
	private int consumerInfoID;
	private int userID;
	private Timestamp applyForTm;
	private String consumerName;
	private String consumerIdentity;
	private String phoneNum1;
	private String phoneNum2;
	private String applyAmount;
	private int loanType;
	private int expenseType;
	private String expenseValue;
	private String earnestMoney;
	private String consumerAddr;
	private String supplementMemo;
	private String contractSignAddr;
	private int pdfinfoUpload;
	private int status;
	private String contractFile;
	
	public int getCompanyID() {
		return companyID;
	}
	public void setCompanyID(int companyID) {
		this.companyID = companyID;
	}
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}	
	public String getContractNo() {
		return contractNo;
	}
	public void setContractNo(String contractNo) {
		this.contractNo = contractNo;
	}
	public int getConsumerInfoID() {
		return consumerInfoID;
	}
	public void setConsumerInfoID(int consumerInfoID) {
		this.consumerInfoID = consumerInfoID;
	}	
	public int getUserID() {
		return userID;
	}
	public void setUserID(int userID) {
		this.userID = userID;
	}
	public Timestamp getApplyForTm() {
		return applyForTm;
	}
	public void setApplyForTm(Timestamp applyForTm) {
		this.applyForTm = applyForTm;
	}
	public String getConsumerName() {
		return consumerName;
	}
	public void setConsumerName(String consumerName) {
		this.consumerName = consumerName;
	}
	public String getConsumerIdentity() {
		return consumerIdentity;
	}
	public void setConsumerIdentity(String consumerIdentity) {
		this.consumerIdentity = consumerIdentity;
	}
	public String getPhoneNum1() {
		return phoneNum1;
	}
	public void setPhoneNum1(String phoneNum1) {
		this.phoneNum1 = phoneNum1;
	}
	public String getPhoneNum2() {
		return phoneNum2;
	}
	public void setPhoneNum2(String phoneNum2) {
		this.phoneNum2 = phoneNum2;
	}
	public String getApplyAmount() {
		return applyAmount;
	}
	public void setApplyAmount(String applyAmount) {
		this.applyAmount = applyAmount;
	}
	public int getLoanType() {
		return loanType;
	}
	public void setLoanType(int loanType) {
		this.loanType = loanType;
	}
	public int getExpenseType() {
		return expenseType;
	}
	public void setExpenseType(int expenseType) {
		this.expenseType = expenseType;
	}
	public String getExpenseValue() {
		return expenseValue;
	}
	public void setExpenseValue(String expenseValue) {
		this.expenseValue = expenseValue;
	}
	public String getEarnestMoney() {
		return earnestMoney;
	}
	public void setEarnestMoney(String earnestMoney) {
		this.earnestMoney = earnestMoney;
	}
	public String getConsumerAddr() {
		return consumerAddr;
	}
	public void setConsumerAddr(String consumerAddr) {
		this.consumerAddr = consumerAddr;
	}
	public String getSupplementMemo() {
		return supplementMemo;
	}
	public void setSupplementMemo(String supplementMemo) {
		this.supplementMemo = supplementMemo;
	}
	public String getContractSignAddr() {
		return contractSignAddr;
	}
	public void setContractSignAddr(String contractSignAddr) {
		this.contractSignAddr = contractSignAddr;
	}	
	public int getPdfinfoUpload() {
		return pdfinfoUpload;
	}
	public void setPdfinfoUpload(int pdfinfoUpload) {
		this.pdfinfoUpload = pdfinfoUpload;
	}	
	public int getStatus() {
		return status;
	}
	public void setStatus(int status) {
		this.status = status;
	}	
	public String getContractFile() {
		return contractFile;
	}
	public void setContractFile(String contractFile) {
		this.contractFile = contractFile;
	}	
	
	
	public void parseFromJson(JSONObject jsonData) {
		if (jsonData.containsKey("consumerInfoID")) {
			this.consumerInfoID = jsonData.getIntValue("consumerInfoID");
		}
		if (jsonData.containsKey("userID")) {
			this.userID = jsonData.getIntValue("userID");
		}
		if (jsonData.containsKey("applyForTm")) {
			long tm = jsonData.getLongValue("applyForTm");
			this.applyForTm = new Timestamp(tm*1000);
		}
		if (jsonData.containsKey("consumerName")) {
			this.consumerName = jsonData.getString("consumerName");
		}
		if (jsonData.containsKey("consumerIdentity")) {
			this.consumerIdentity = jsonData.getString("consumerIdentity");
		}
		if (jsonData.containsKey("phoneNum1")) {
			this.phoneNum1 = jsonData.getString("phoneNum1");
		}
		if (jsonData.containsKey("phoneNum2")) {
			this.phoneNum2 = jsonData.getString("phoneNum2");
		}
		if (jsonData.containsKey("applyAmount")) {
			this.applyAmount = jsonData.getString("applyAmount");
		}
		if (jsonData.containsKey("loanType")) {
			this.loanType = jsonData.getIntValue("loanType");
		}
		if (jsonData.containsKey("expenseType")) {
			this.expenseType = jsonData.getIntValue("expenseType");
		}
		if (jsonData.containsKey("expenseValue")) {
			this.expenseValue = jsonData.getString("expenseValue");
		}
		if (jsonData.containsKey("earnestMoney")) {
			this.earnestMoney = jsonData.getString("earnestMoney");
		}
		if (jsonData.containsKey("consumerAddr")) {
			this.consumerAddr = jsonData.getString("consumerAddr");
		}
		if (jsonData.containsKey("supplementMemo")) {
			this.supplementMemo = jsonData.getString("supplementMemo");
		}
		if (jsonData.containsKey("contractSignAddr")) {
			this.contractSignAddr = jsonData.getString("contractSignAddr");
		}		
	}
	
	
	public JSONObject toJSONObject() {
		JSONObject jsonObj = new JSONObject();
		if (id > 0) {
			jsonObj.put("id", id);
		}
		if (contractNo != null && contractNo.length() > 0) {
			jsonObj.put("contractNo", contractNo);
		}
		if (consumerInfoID > 0) {
			jsonObj.put("consumerInfoID", consumerInfoID);
		}
		if (userID > 0) {
			jsonObj.put("userID", userID);
		}
		if (applyForTm != null) {
			long tm = applyForTm.getTime() / 1000;
			jsonObj.put("applyForTm", tm);
		}
		if (consumerName != null && consumerName.length() > 0) {
			jsonObj.put("consumerName", consumerName);
		}
		if (consumerIdentity != null && consumerIdentity.length() > 0) {
			jsonObj.put("consumerIdentity", consumerIdentity);
		}
		if (phoneNum1 != null && phoneNum1.length() > 0) {
			jsonObj.put("phoneNum1", phoneNum1);
		}
		if (phoneNum2 != null && phoneNum2.length() > 0) {
			jsonObj.put("phoneNum2", phoneNum2);
		}
		if (applyAmount != null && applyAmount.length() > 0) {
			jsonObj.put("applyAmount", applyAmount);
		}
		if (loanType > 0) {
			jsonObj.put("loanType", loanType);
		}
		if (expenseType > 0) {
			jsonObj.put("expenseType", expenseType);
		}
		if (expenseValue != null && expenseValue.length() > 0) {
			jsonObj.put("expenseValue", expenseValue);
		}
		if (earnestMoney != null && earnestMoney.length() > 0) {
			jsonObj.put("earnestMoney", earnestMoney);
		}
		if (consumerAddr != null && consumerAddr.length() > 0) {
			jsonObj.put("consumerAddr", consumerAddr);
		}
		if (supplementMemo != null && supplementMemo.length() > 0) {
			jsonObj.put("supplementMemo", supplementMemo);
		}
		if (contractSignAddr != null && contractSignAddr.length() > 0) {
			jsonObj.put("contractSignAddr", contractSignAddr);
		}
		jsonObj.put("pdfinfoUpload", pdfinfoUpload);
		jsonObj.put("status", status);
		if (contractFile != null && contractFile.length() > 0) {
			jsonObj.put("contractFile", contractFile);			
		}
		
		return jsonObj;
	}
	
}
